<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>微信带参数的二维码管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/wechat/wechatScene/">微信带参数的二维码列表</a></li>
		<shiro:hasPermission name="wechat:wechatScene:edit"><li><a href="${ctx}/wechat/wechatScene/form">微信带参数的二维码添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="wechatScene" action="${ctx}/wechat/wechatScene/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<label>名称 ：</label><form:input path="scene" htmlEscape="false" maxlength="50" class="input-medium"/>
		&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
	</form:form>
	<tags:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered ">
		<thead><tr><th>所属商家</th><th>场景值</th><th>场景</th><th>二维码类型</th><shiro:hasPermission name="wechat:wechatScene:edit"><th>操作</th></shiro:hasPermission></tr></thead>
		<tbody>
		<c:forEach items="${page.list}" var="wechatScene">
			<tr>
				<td><a href="${ctx}/wechat/wechatScene/form?id=${wechatScene.id}">${wechatScene.user.name}</a></td>
				<td><a href="${ctx}/wechat/wechatScene/form?id=${wechatScene.id}">${wechatScene.sceneId}</a></td>
				<td><a href="${ctx}/wechat/wechatScene/form?id=${wechatScene.id}">${wechatScene.scene}</a></td>
				<td><a href="${ctx}/wechat/wechatScene/form?id=${wechatScene.id}">${wechatScene.qrcodeType}</a></td>
				<shiro:hasPermission name="wechat:wechatScene:edit"><td>
    				<a class="btn btn-success" href="${ctx}/wechat/wechatScene/form?id=${wechatScene.id}">修改</a>
	    			<button type="button" class="btn btn-success" data-toggle="modal" data-target="#myModal_${wechatScene.id }">查看二维码</button>
					<a class="btn btn-danger" href="${ctx}/wechat/wechatScene/delete?id=${wechatScene.id}" onclick="return confirmx('确认要删除该微信带参数的二维码吗？', this.href)">删除</a>
						<!-- 回复内容 -->
						<div id="myModal_${wechatScene.id}" class="modal hide fade" tabindex="-1" style="width:300px"
									role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
									<div class="modal-header">
										<button type="button" class="close" data-dismiss="modal"
											aria-hidden="true">×</button>
										<h3 id="myModalLabel">查看二维码</h3>
									</div>
									<div class="modal-body">
									<c:if test="${!empty wechatScene.ticket}">
										<img src="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=${wechatScene.ticket }">
									</c:if>
									<c:if test="${empty  wechatScene.ticket}">二维码生成失败</c:if>
									</div>
									<div class="modal-footer">
										<button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
									</div>
						</div> <!-- 回复内容 结束-->
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>
